package com.loveprogrammer.eternity.skill.support.skills;

import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.common.Tuple;
import com.loveprogrammer.eternity.skill.support.states.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0.0
 * @description: 巨人形态
 * @author: eric
 * @date: 2022-08-11 16:49
 **/
public class SkillColossusForm extends AbstractSkill {

    public SkillColossusForm(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
    }

    @Override
    public boolean check(Character character) {
        return true;
    }

    @Override
    public int opportunityPassive() {
        // 主动技能
        return 0;
    }

    @Override
    public boolean checkLevelUp(int characterLevel) {
        // 每5级升一级
        if (characterLevel % 5 == 0) {
            return true;
        }
        return false;
    }

    /***
     * 发动技能
     **/
    @Override
    public Tuple<String, List<Character>> skillLaunch(Character character,
                                                      List<? extends Character> attack,
                                                      List<? extends Character> defences) {
        Tuple<String, List<Character>> result = new Tuple<>();

        List<Character> characters = new ArrayList<>();

        // 增加力量 技巧 护甲 抗性 持续5s钟
        int power = getHarm(character);
        StringBuilder builder = new StringBuilder();
        builder.append(character.getName()).append("(").append(character.getCurrentHp()).append("/")
                .append(character.getHpMax()).append(")").append(" 使用技能[")
                .append(getName()).append(" ").append(getLevel()).append("级】增加了自身力量 ").append(power).append("点,持续持续8s");
        // 战吼
        StrengthState strengthState = new StrengthState(character, defences, power);
        character.acquireState(strengthState,8);
        character.setStrength(character.getStrength() + power);
        setTimeTask(strengthState, 8);

        // 技巧
        // power = (int) (character.getStrength() * 0.1 * getLevel() + 50);
        builder.append("增加了自身技巧 ").append(power).append("点");
        TechIncrState techIncrState = new TechIncrState(character, defences, power);
        character.acquireState(techIncrState,8);
        character.setTechnique(character.getTechnique() + power);
        setTimeTask(techIncrState, 8);

        // 护甲
//        power = (int) (character.getArmature() * 0.1 * getLevel() + 20);
//        builder.append("增加了自身护甲 ").append(power).append("点");
//        ArmourIncrState tauntState = new ArmourIncrState(character, defences, power);
//        character.acquireState(tauntState,8);
//        character.setArmature(character.getArmature() + power);
//        setTimeTask(tauntState, 8);

        // 法力
//        power = (int) (character.getMagic() * 0.1 * getLevel() + 50);
//        builder.append("增加了自身法力").append(power).append("点");
//        MagicIncrState magicIncrState = new MagicIncrState(character, defences, power);
//        character.acquireState(magicIncrState,5);
//        character.setMagic(character.getMagic() + power);
//        setTimeTask(magicIncrState, 5);

        // 其他抗性
        power = 15 + getLevel();
        builder.append("增加了自身毒、火、雷抗性 ").append(power).append("点");
        ResistenceIncrState resistenceIncrState = new ResistenceIncrState(character, defences, power);
        character.setPoisonResistance(character.getPoisonResistance() + power);
        character.setFlameResistance(character.getFlameResistance() + power);
        character.setThunderResistance(character.getThunderResistance() + power);
        character.acquireState(resistenceIncrState,8);



        setTimeTask(resistenceIncrState, 8);

        // 生命恢复速度 每秒恢复生命值的 110 + 1/20
        power = (int) (110 + character.getHpMax() * 0.05);
        builder.append("增加了恢复生命力每秒 ").append(power).append("点");
        TreatmentState treatmentState = new TreatmentState(character, defences, power);
        setTimeTask(treatmentState, 8);

        result.setValue(characters);
        result.setKey(builder.toString());
        return result;
    }

    @Override
    protected int computeHarm(Character character) {
        return  (int) (character.getStrength() * 0.1 + getLevel() * 100);
    }

    @Override
    protected int computeSecondHarm(Character character) {
        return 0;
    }
}
